package com.sumainfor.pc.cfo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.cfo.service.HouseRentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-04-18 10:29
 * 房租收款
 */
@RestController
@RequestMapping("/houseRent")
public class HouseRentController {

    @Autowired
    private HouseRentService hrs;

    /**
     * 查询唐巢收入信息 房租 公共事业 维修 夜间开门 退租 其他 主页数据
     *
     * @param page
     * @param params
     * @return
     */
    @RequestMapping("/selectOrderInTableList")
    public JsonResult selectOrderInTableList(Page page, @RequestParam Map<String, Object> params) {
        if (!FieldCheckUtil.isMapFieldNotNull(params, "Status", "BiType")) {
            return JsonResult.errorForEmpty();
        }
        return hrs.selectOrderInTableList(page, params);
    }


    /**
     * 查询唐巢支出账单
     * 账单类型  1.业主   2.供应商  3.退租账单   4.公共事业费
     *
     * @param page
     * @param params
     * @return
     */
    @RequestMapping("/selectOrderOutTableList")
    public JsonResult selectOrderOutTableList(Page page, @RequestParam Map<String, Object> params) {
        return hrs.selectOrderOutTableList(page, params);
    }


    /**
     * 唐巢支付 设置支付成功接口
     *
     * @param biOutId
     * @return
     */
    @PostMapping("/setPayDone")
    public JsonResult setPayDone(String biOutId) {
        if (StringUtils.isBlank(biOutId)) {
            return JsonResult.errorForEmpty();
        }
        return hrs.setPayDone(biOutId);
    }

}
